<template>
  <div
    class="gdap-collegeRcmm"
    style="width: 100%; height: 90%; background: white; margin: 0 auto; overflow: auto; padding-bottom: 30px;"
  >
    <p
      style="  font-family:SiYuanBold;color:rgb(207, 139, 50);font-size:30px;text-align: center;"
    >院校录取预测</p>
    <el-row :gutter="0" style="padding-top:1%">
      <el-form ref="estimateForm" :model="estimateForm" :rules="formRules" :inline="true">
        <div style="width:60%;margin:0 20%">
          <el-row>
            <el-col :span="6">
              <label
                for="1"
                style="text-align: right;
    vertical-align: middle;
    font-size: 16px;
    color: #000;
    line-height: 2.5em;
    padding: 0 12px 0 0;
    box-sizing: border-box;"
              >语种</label>

              <el-form-item>
                <el-select
                  v-model="estimateForm.languageValue"
                  placeholder="Select"
                  size="small"
                  @change="fnChange"
                  style="width:10em"
                >
                  <el-option
                    v-for="item in languageList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <label
                for="1"
                style="text-align: right;
    vertical-align: middle;
    font-size: 16px;
    color: #000;
    line-height: 2.5em;
    padding: 0 12px 0 0;
    box-sizing: border-box;"
              >科类</label>

              <el-form-item>
                <el-select
                  v-model="estimateForm.cateValue"
                  placeholder="Select"
                  size="small"
                  @change="fnChange"
                  style="width:10em"
                >
                  <el-option
                    v-for="item in categoryList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <label
                for="1"
                style="
                vertical-align: middle;
                font-size: 16px;
                color: #000;
                line-height: 2.5em;
                padding: 0 12px 0 0;
                box-sizing: border-box;"
              >分数</label>
              <el-form-item prop="score">
                <el-input
                  :controls="false"
                  size="small"
                  placeholder="请输入分数"
                  v-model.number="estimateForm.score"
                  style="width: 10em;"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6" style="margin-left:1em" v-if="VERSION_NO === 0">
              <p style="color:red" v-show="estimateRate">预估排名为{{estimateForm.rate}}</p>
            </el-col>
            <el-col :span="6" v-else>
              <label
                for="1"
                style="
                vertical-align: middle;
                font-size: 16px;
                color: #000;
                line-height: 2.5em;
                padding: 0 12px 0 0;
                box-sizing: border-box;"
              >排名</label>
              <el-form-item prop="rate">
                <el-input
                  placeholder="请输入实际排名"
                  v-model.number="estimateForm.rate"
                  size="small"
                  :controls="false"
                  style="width: 10em;"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <!-- <p style="color:red">预估排名为{{estimateForm.rate}}</p> -->
        </div>
      </el-form>
      <!-- <el-col :span="2">
        <label for="1" style="text-align: right;
    vertical-align: middle;
    float: right;
    font-size: 16px;
    color: #fff;
    line-height: 25px;
    padding: 0 12px 0 0;
    box-sizing: border-box;">
          语种
        </label>

      </el-col>
      <el-col :span="3">
        <el-select v-model="language" @change="fnChange" size="mini">
          <el-option v-for="item in languageList" :key="item.value" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-col>

      <el-col :span="2">
        <label for="1" style="text-align: right;
    vertical-align: middle;
    float: right;
    font-size: 16px;
    color: #fff;
    line-height: 25px;
    padding: 0 12px 0 0;
    box-sizing: border-box;">
          科类
        </label>
      </el-col>
      <el-col :span="3">
        <el-select v-model="category" @change="fnChange" size="mini">
          <el-option v-for="item in categoryList" :key="item.value" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-col>

      <el-col :span="2">
        <label for="1" style="text-align: right;
    vertical-align: middle;
    float: right;
    font-size: 16px;
    color: #fff;
    line-height: 25px;
    padding: 0 12px 0 0;
    box-sizing: border-box;">
          分数
        </label>
      </el-col>

      <el-col :span="5">
        <el-input placeholder="请输入0~750的正整数" type="text" clearable v-model="score" size="mini">
        </el-input>
      </el-col>-->
    </el-row>
    
    <el-row :gutter="0" style="padding-bottom:1%;margin:0 auto;text-align:center">
      
      
        <el-input placeholder="院校名称" clearable v-model="searchName" style="width:18em;margin:0 0.5em"></el-input>
         <el-select v-model="areaValue" clearable placeholder="地域" style="width:10em;margin:0 1em">
          <el-option v-for="(item, index) in areaList" :key="index" :label="item" :value="item"></el-option>
        </el-select>
        <el-button type="primary" icon="el-icon-search" @click="search()">搜索</el-button>
    
      
    </el-row>
   
    <el-row>
      <div class="gdap-checkgroup" style="width:70%;text-align:center;margin:0 auto">
        <div @click="fnCheckGroup(1)">
          <el-col
            :span="8"
            style="text-align: center;padding: 0.5em;border-right: 1px solid #ccc;cursor: pointer;"
            :class="{ 'gdap-check-active': currentId == 1}"
          >一批</el-col>
        </div>
        <div @click="fnCheckGroup(2)">
          <el-col
            :span="8"
            style="text-align: center;padding: 0.5em;border-right: 1px solid #ccc;cursor: pointer;"
            :class="{ 'gdap-check-active': currentId == 2}"
          >二批</el-col>
        </div>
        <div @click="fnCheckGroup(5)">
          <el-col
            :span="8"
            style="text-align: center;padding: 0.5em;cursor: pointer;"
            :class="{ 'gdap-check-active': currentId == 5}"
          >专科</el-col>
        </div>
      </div>
    </el-row>

    <el-row style="padding-top: 0.5em;padding-bottom: 0.5em;border-bottom: 1px solid #ccc;">
      <el-col :span="24" style="text-align: center;">
        <el-radio-group v-model="selectAlpha" size="small">
          <el-radio-button
            border
            v-for="(item,key) in objCollege"
            :label="key"
            :key="item.yxdm"
            v-show="item.length>0"
          >{{key}}</el-radio-button>
        </el-radio-group>
      </el-col>
    </el-row>

    <el-row style="background-color: #fff;width:70%;text-align:center;margin:0 auto">
      <el-col :span="22" :offset="1" style="height: 40vh;overflow-y: auto;">
        <el-col
          :span="10"
          v-for="item in currentList"
          :label="item.name"
          :key="item.id"
          style="margin:0.8em;overflow: hidden;text-align:center"
        >
          <el-radio
            :label="item"
            v-model="selectCollege"
            :disabled="estimateForm.score==''"
          >{{item.name}}</el-radio>
        </el-col>
        <el-col :span="24" style="text-align:center;" v-if="currentList.length <=0">
          <h1>暂无结果</h1>
        </el-col>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="5" :offset="7">
        <el-button style="width: 15em;" @click="cancel">返回首页</el-button>
      </el-col>
      <el-col :span="5" :offset="1">
        <el-button type="primary" style="width: 15em;" @click="submit">确定</el-button>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import api from "@/utils/api";
import {
  languageList,
  categoryList,
  VERSION_NO,
  areaList
} from "../../constants/constants";
export default {
  data() {
    var checkScore = (rule, value, cb) => {
      if (!value && value !== 0) {
        return cb(new Error("必须填写分数"));
      }
      setTimeout(() => {
        if (Number(value) <= 0 || Number(value) > 750) {
          cb(new Error("请填写1到750之间的整数"));
          this.estimateForm.score = "";
        } else {
          cb();
        }
      });
    };
    var checkRate = (rule, value, cb) => {
      if (!value) {
        return cb(new Error("必须填写排名"));
      }
      setTimeout(() => {
        if (Number(value) <= 0 || Number(value) > 100000) {
          cb(new Error("请填写1到100000之间的整数"));
        } else {
          cb();
        }
      });
    };
    return {
      areaValue: "",
      areaList: areaList,
      estimateForm: {
        languageValue: localStorage.getItem("user")
          ? JSON.parse(localStorage.getItem("user")).yzmc
          : "",
        cateValue: localStorage.getItem("user")
          ? JSON.parse(localStorage.getItem("user")).kldm
          : "",
        score: "",
        rate: ""
      },
      formRules: {
        score: [
          { validator: checkScore, trigger: "blur" },
          { type: "number", message: "请填入0~750之间的整数" }
        ],
        rate: [
          { validator: checkRate, trigger: "blur" },
          { type: "number", message: "实际排名必须为整数" }
        ]
      },
      VERSION_NO: "",
      estimateRate: false,
      alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
      alphabetObject1: {},
      alphabetObject2: {},
      alphabetObject5: {},
      total: {},
      selectAlpha: "A",
      checkGroup: "",
      searchName: "",
      objCollege: "",
      currentList: "",
      selectCollege: "",
      currentId: "",
      group1: "",
      group2: "",
      group5: "",
      score: "",
      languageList: languageList,
      categoryList: categoryList,
      examYear: "2018"
    };
  },
  methods: {
    fnChange() {
      var _object1 = new Object();
      var _object2 = new Object();
      var _object5 = new Object();
      for (let i = 0; i < this.alphabet.length; i++) {
        const element = this.alphabet[i];
        var value = element;
        _object1[value] = [];
        _object2[value] = [];
        _object5[value] = [];
      }
      this.alphabetObject1 = "";
      this.alphabetObject2 = "";
      this.alphabetObject5 = "";

      this.alphabetObject1 = _object1;
      this.alphabetObject2 = _object2;
      this.alphabetObject5 = _object5;
      this.getCollege();
    },
    getCollege() {
      var params = {
        kldm: this.estimateForm.cateValue,
        yzmc: this.estimateForm.languageValue,
        year: this.examYear
      };

      api({
        url: "/nceeSysMgr/rest/sendPost/analysis/rest/getYXs",
        method: "post",
        data: params
      })
        .then(res => {
          if (res.status == 200) {
            if (JSON.stringify(res.data) !== "{}") {
              this.total = res.data;
              var data = res.data;
              for (const key in data) {
                if (data.hasOwnProperty(key)) {
                  const k_element = data[key];

                  if (key == "1") {
                    for (let i = 0; i < k_element.length; i++) {
                      const i_element = k_element[i];
                      for (const key in this.alphabetObject1) {
                        if (this.alphabetObject1.hasOwnProperty(key)) {
                          const key_element = this.alphabetObject1[key];
                          if (key == i_element.pId) {
                            key_element.push(i_element);
                          }
                        }
                      }
                    }
                  }

                  if (key == "2") {
                    for (let i = 0; i < k_element.length; i++) {
                      const i_element = k_element[i];
                      for (const key in this.alphabetObject2) {
                        if (this.alphabetObject2.hasOwnProperty(key)) {
                          const key_element = this.alphabetObject2[key];
                          if (key == i_element.pId) {
                            key_element.push(i_element);
                          }
                        }
                      }
                    }
                  }

                  if (key == "5") {
                    for (let i = 0; i < k_element.length; i++) {
                      const i_element = k_element[i];
                      for (const key in this.alphabetObject5) {
                        if (this.alphabetObject5.hasOwnProperty(key)) {
                          const key_element = this.alphabetObject5[key];
                          if (key == i_element.pId) {
                            key_element.push(i_element);
                          }
                        }
                      }
                    }
                  }
                }
              }
              this.currentId = 1;
              this.fnCheckGroup(1);
              // this.objCollege = this.alphabetObject1
              // this.currentList = this.alphabetObject1['A']
              // this.selectAlpha = 'A'
            } else {
            }
          }
        })
        .catch(e => {
          console.error(e);
        });
    },
    search() {
      console.log(this.searchName, ' search name')
      console.log(this.areaValue, ' areaValue')
      if (this.searchName != "" && this.areaValue === "") {
        //初始化一个承载缓存数据的容器
        // var _object1 = new Object();
        // var _object2 = new Object();
        // var _object5 = new Object();
        // for (let i = 0; i < this.alphabet.length; i++) {
        //   const element = this.alphabet[i];
        //   var value = element;
        //   _object1[value] = [];
        //   _object2[value] = [];
        //   _object5[value] = [];
        // }
        // this.alphabetObject1 = "";
        // this.alphabetObject2 = "";
        // this.alphabetObject5 = "";

        // this.alphabetObject1 = _object1;
        // this.alphabetObject2 = _object2;
        // this.alphabetObject5 = _object5;
        // var data = this.total;
        // for (const key in data) {
        //   if (data.hasOwnProperty(key)) {
        //     const k_element = data[key];

        //     if (key == "1") {
        //       for (let i = 0; i < k_element.length; i++) {
        //         const i_element = k_element[i];
        //         for (const key in this.alphabetObject1) {
        //           if (this.alphabetObject1.hasOwnProperty(key)) {
        //             const key_element = this.alphabetObject1[key];
        //             if (key == i_element.pId) {
        //               if (i_element.name.search(this.searchName) != -1) {
        //                 key_element.push(i_element);
        //               }
        //             }
        //           }
        //         }
        //       }
        //     }

        //     if (key == "2") {
        //       for (let i = 0; i < k_element.length; i++) {
        //         const i_element = k_element[i];
        //         for (const key in this.alphabetObject2) {
        //           if (this.alphabetObject2.hasOwnProperty(key)) {
        //             const key_element = this.alphabetObject2[key];
        //             if (key == i_element.pId) {
        //               if (i_element.name.search(this.searchName) != -1) {
        //                 key_element.push(i_element);
        //               }
        //             }
        //           }
        //         }
        //       }
        //     }

        //     if (key == "5") {
        //       for (let i = 0; i < k_element.length; i++) {
        //         const i_element = k_element[i];
        //         for (const key in this.alphabetObject5) {
        //           if (this.alphabetObject5.hasOwnProperty(key)) {
        //             const key_element = this.alphabetObject5[key];
        //             if (key == i_element.pId) {
        //               if (i_element.name.search(this.searchName) != -1) {
        //                 key_element.push(i_element);
        //               }
        //             }
        //           }
        //         }
        //       }
        //     }
        //   }
        // }

        // this.objCollege = "";
        // this.currentList = "";
        // this.currentId = 1;
        // // this.objCollege = this.alphabetObject1
        // // this.currentList = this.alphabetObject1['A']
        // // this.selectAlpha = 'A'
        // this.fnCheckGroup(1);
        var params = {
          kldm: this.estimateForm.cateValue,
          yzmc: this.estimateForm.languageValue,
          year: this.examYear,
          area: this.areaValue
        };
        api({
          url: "/nceeSysMgr/rest/sendPost/analysis/rest/getYXs",
          method: "post",
          data: params
        })
          .then(res => {
            if (res.status == 200) {
              if (JSON.stringify(res.data) !== "{}") {
                this.total = res.data;
                var data = res.data;
                
                // this.objCollege = this.alphabetObject1
                // this.currentList = this.alphabetObject1['A']
                // this.selectAlpha = 'A'
                var _object1 = new Object();
                var _object2 = new Object();
                var _object5 = new Object();
                for (let i = 0; i < this.alphabet.length; i++) {
                  const element = this.alphabet[i];
                  var value = element;
                  _object1[value] = [];
                  _object2[value] = [];
                  _object5[value] = [];
                }
                this.alphabetObject1 = "";
                this.alphabetObject2 = "";
                this.alphabetObject5 = "";

                this.alphabetObject1 = _object1;
                this.alphabetObject2 = _object2;
                this.alphabetObject5 = _object5;
                var data = this.total;
                for (const key in data) {
                  if (data.hasOwnProperty(key)) {
                    const k_element = data[key];

                    if (key == "1") {
                      for (let i = 0; i < k_element.length; i++) {
                        const i_element = k_element[i];
                        for (const key in this.alphabetObject1) {
                          if (this.alphabetObject1.hasOwnProperty(key)) {
                            const key_element = this.alphabetObject1[key];
                            if (key == i_element.pId) {
                              if (
                                i_element.name.search(this.searchName) != -1
                              ) {
                                key_element.push(i_element);
                              }
                            }
                          }
                        }
                      }
                    }

                    if (key == "2") {
                      for (let i = 0; i < k_element.length; i++) {
                        const i_element = k_element[i];
                        for (const key in this.alphabetObject2) {
                          if (this.alphabetObject2.hasOwnProperty(key)) {
                            const key_element = this.alphabetObject2[key];
                            if (key == i_element.pId) {
                              if (
                                i_element.name.search(this.searchName) != -1
                              ) {
                                key_element.push(i_element);
                              }
                            }
                          }
                        }
                      }
                    }

                    if (key == "5") {
                      for (let i = 0; i < k_element.length; i++) {
                        const i_element = k_element[i];
                        for (const key in this.alphabetObject5) {
                          if (this.alphabetObject5.hasOwnProperty(key)) {
                            const key_element = this.alphabetObject5[key];
                            if (key == i_element.pId) {
                              if (
                                i_element.name.search(this.searchName) != -1
                              ) {
                                key_element.push(i_element);
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }

                this.objCollege = "";
                this.currentList = "";
                this.currentId = 1;
                // this.objCollege = this.alphabetObject1
                // this.currentList = this.alphabetObject1['A']
                // this.selectAlpha = 'A'
                this.fnCheckGroup(1);
              } else {
              }
            }
          })
          .catch(e => {
            console.error(e);
          });
      } else if (this.searchName === "" && this.areaValue !== "") {
        var params = {
          kldm: this.estimateForm.cateValue,
          yzmc: this.estimateForm.languageValue,
          year: this.examYear,
          area: this.areaValue
        };
        api({
          url: "/nceeSysMgr/rest/sendPost/analysis/rest/getYXs",
          method: "post",
          data: params
        })
          .then(res => {
            if (res.status == 200) {
              if (JSON.stringify(res.data) !== "{}") {
                this.total = res.data;
                var data = res.data;
                
                // this.objCollege = this.alphabetObject1
                // this.currentList = this.alphabetObject1['A']
                // this.selectAlpha = 'A'
                var _object1 = new Object();
                var _object2 = new Object();
                var _object5 = new Object();
                for (let i = 0; i < this.alphabet.length; i++) {
                  const element = this.alphabet[i];
                  var value = element;
                  _object1[value] = [];
                  _object2[value] = [];
                  _object5[value] = [];
                }
                this.alphabetObject1 = "";
                this.alphabetObject2 = "";
                this.alphabetObject5 = "";

                this.alphabetObject1 = _object1;
                this.alphabetObject2 = _object2;
                this.alphabetObject5 = _object5;
                var data = this.total;
                for (const key in data) {
                  if (data.hasOwnProperty(key)) {
                    const k_element = data[key];

                    if (key == "1") {
                      for (let i = 0; i < k_element.length; i++) {
                        const i_element = k_element[i];
                        for (const key in this.alphabetObject1) {
                          if (this.alphabetObject1.hasOwnProperty(key)) {
                            const key_element = this.alphabetObject1[key];
                            if (key == i_element.pId) {
                              if (
                                i_element.name.search(this.searchName) != -1
                              ) {
                                key_element.push(i_element);
                              }
                            }
                          }
                        }
                      }
                    }

                    if (key == "2") {
                      for (let i = 0; i < k_element.length; i++) {
                        const i_element = k_element[i];
                        for (const key in this.alphabetObject2) {
                          if (this.alphabetObject2.hasOwnProperty(key)) {
                            const key_element = this.alphabetObject2[key];
                            if (key == i_element.pId) {
                              if (
                                i_element.name.search(this.searchName) != -1
                              ) {
                                key_element.push(i_element);
                              }
                            }
                          }
                        }
                      }
                    }

                    if (key == "5") {
                      for (let i = 0; i < k_element.length; i++) {
                        const i_element = k_element[i];
                        for (const key in this.alphabetObject5) {
                          if (this.alphabetObject5.hasOwnProperty(key)) {
                            const key_element = this.alphabetObject5[key];
                            if (key == i_element.pId) {
                              if (
                                i_element.name.search(this.searchName) != -1
                              ) {
                                key_element.push(i_element);
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }

                this.objCollege = "";
                this.currentList = "";
                this.currentId = 1;
                // this.objCollege = this.alphabetObject1
                // this.currentList = this.alphabetObject1['A']
                // this.selectAlpha = 'A'
                this.fnCheckGroup(1);
              } else {
              }
            }
          })
          .catch(e => {
            console.error(e);
          });
      } else if (this.searchName !== '' && this.areaValue !== '') {
        var params = {
          kldm: this.estimateForm.cateValue,
          yzmc: this.estimateForm.languageValue,
          year: this.examYear,
          area: this.areaValue
        };
        api({
          url: "/nceeSysMgr/rest/sendPost/analysis/rest/getYXs",
          method: "post",
          data: params
        })
          .then(res => {
            if (res.status == 200) {
              if (JSON.stringify(res.data) !== "{}") {
                this.total = res.data;
                var data = res.data;
                
                // this.objCollege = this.alphabetObject1
                // this.currentList = this.alphabetObject1['A']
                // this.selectAlpha = 'A'
                var _object1 = new Object();
                var _object2 = new Object();
                var _object5 = new Object();
                for (let i = 0; i < this.alphabet.length; i++) {
                  const element = this.alphabet[i];
                  var value = element;
                  _object1[value] = [];
                  _object2[value] = [];
                  _object5[value] = [];
                }
                this.alphabetObject1 = "";
                this.alphabetObject2 = "";
                this.alphabetObject5 = "";

                this.alphabetObject1 = _object1;
                this.alphabetObject2 = _object2;
                this.alphabetObject5 = _object5;
                var data = this.total;
                for (const key in data) {
                  if (data.hasOwnProperty(key)) {
                    const k_element = data[key];

                    if (key == "1") {
                      for (let i = 0; i < k_element.length; i++) {
                        const i_element = k_element[i];
                        for (const key in this.alphabetObject1) {
                          if (this.alphabetObject1.hasOwnProperty(key)) {
                            const key_element = this.alphabetObject1[key];
                            if (key == i_element.pId) {
                              if (
                                i_element.name.search(this.searchName) != -1
                              ) {
                                key_element.push(i_element);
                              }
                            }
                          }
                        }
                      }
                    }

                    if (key == "2") {
                      for (let i = 0; i < k_element.length; i++) {
                        const i_element = k_element[i];
                        for (const key in this.alphabetObject2) {
                          if (this.alphabetObject2.hasOwnProperty(key)) {
                            const key_element = this.alphabetObject2[key];
                            if (key == i_element.pId) {
                              if (
                                i_element.name.search(this.searchName) != -1
                              ) {
                                key_element.push(i_element);
                              }
                            }
                          }
                        }
                      }
                    }

                    if (key == "5") {
                      for (let i = 0; i < k_element.length; i++) {
                        const i_element = k_element[i];
                        for (const key in this.alphabetObject5) {
                          if (this.alphabetObject5.hasOwnProperty(key)) {
                            const key_element = this.alphabetObject5[key];
                            if (key == i_element.pId) {
                              if (
                                i_element.name.search(this.searchName) != -1
                              ) {
                                key_element.push(i_element);
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }

                this.objCollege = "";
                this.currentList = "";
                this.currentId = 1;
                // this.objCollege = this.alphabetObject1
                // this.currentList = this.alphabetObject1['A']
                // this.selectAlpha = 'A'
                this.fnCheckGroup(1);
              } else {
              }
            }
          })
          .catch(e => {
            console.error(e);
          });
      } else {
        var _object1 = new Object();
        var _object2 = new Object();
        var _object5 = new Object();
        for (let i = 0; i < this.alphabet.length; i++) {
          const element = this.alphabet[i];
          var value = element;
          _object1[value] = [];
          _object2[value] = [];
          _object5[value] = [];
        }
        this.alphabetObject1 = "";
        this.alphabetObject2 = "";
        this.alphabetObject5 = "";

        this.alphabetObject1 = _object1;
        this.alphabetObject2 = _object2;
        this.alphabetObject5 = _object5;
        this.getCollege();
      }
    },
    cancel() {
      this.selectCollege = "";
      this.$router.push("/");
    },
    submit() {
      if (JSON.parse(localStorage.getItem("user")).editXYNum <= 0) {
        this.$message({
          message: "您还未购买产品，即将跳转支付页面",
          type: "warning"
        });
        setTimeout(() => {
          this.$router.push("/paymentrecord");
        });
      } else {
        if (this.estimateForm.score === "" || this.estimateForm.rate === "") {
          this.$notify({
            message: "分数和排名必填",
            type: "error"
          });
        } else {
          this.$router.push({
            name: "estimatecolleage",
            params: {
              yxdm: this.selectCollege.id,
              kldm: this.estimateForm.cateValue,
              yzmc: this.estimateForm.languageValue,
              px: this.estimateForm.rate + "",
              zf: this.estimateForm.score + ""
            }
          });
        }

        const params = {
          kldm: this.estimateForm.cateValue,
          px: this.estimateForm.rate + "",
          yzmc: this.estimateForm.languageValue,
          zf: this.estimateForm.score + "",
          yxdm: this.selectCollege.id
        };
        localStorage.setItem("estimateparam", JSON.stringify(params));
      }
    },
    fnCheckGroup(id) {
      this.currentId = id;
      if (id == 1) {
        this.objCollege = this.alphabetObject1;

        for (const key in this.alphabetObject1) {
          if (this.alphabetObject1.hasOwnProperty(key)) {
            const element = this.alphabetObject1[key];
            if (element.length > 0) {
              this.selectAlpha = key;
              break;
            }
          }
        }
        this.currentList = this.alphabetObject1[this.selectAlpha];
      } else if (id == 2) {
        this.objCollege = this.alphabetObject2;

        for (const key in this.alphabetObject2) {
          if (this.alphabetObject2.hasOwnProperty(key)) {
            const element = this.alphabetObject2[key];
            if (element.length > 0) {
              this.selectAlpha = key;
              break;
            }
          }
        }
        this.currentList = this.alphabetObject2[this.selectAlpha];
      } else {
        this.objCollege = this.alphabetObject5;
        for (const key in this.alphabetObject5) {
          if (this.alphabetObject5.hasOwnProperty(key)) {
            const element = this.alphabetObject5[key];
            if (element.length > 0) {
              this.selectAlpha = key;
              break;
            }
          }
        }
        this.currentList = this.alphabetObject5[this.selectAlpha];
      }
    }
  },
  mounted() {
    //初始化一个承载缓存数据的容器
    var _object1 = new Object();
    var _object2 = new Object();
    var _object5 = new Object();
    for (let i = 0; i < this.alphabet.length; i++) {
      const element = this.alphabet[i];
      var value = element;
      _object1[value] = [];
      _object2[value] = [];
      _object5[value] = [];
    }
    this.alphabetObject1 = _object1;
    this.alphabetObject2 = _object2;
    this.alphabetObject5 = _object5;
    var data = JSON.parse(localStorage.getItem("user"));
    this.username = data.userId;
    this.getCollege();
  },
  watch: {
    selectAlpha: function(val) {
      if (val !== "") {
        this.currentList = this.objCollege[val];
      }
    },
    score: function(val) {
      if (val != "") {
        var reg = /^[0-9]*$/;
        if (reg.test(val)) {
          if (val * 1 > 750) {
            this.score = "";
            this.$message({
              message: "高考总分只有750分。(￣.￣)",
              type: "warning",
              duration: "2000"
            });
          }
        } else {
          this.$message({
            message: "只能输入合法的数字",
            type: "warning",
            duration: "1000"
          });
          this.score = "";
        }
      }
    },
    estimateForm: {
      handler: function(old, newVal) {
        if (VERSION_NO === 0) {
          this.estimateRate =
            old.score > 0 && old.score !== "" && old.score <= 750
              ? true
              : false;
          if (
            this.estimateForm.cateValue !== null &&
            this.estimateForm.languageValue !== null
          ) {
            api({
              url: "/nceeSysMgr/rest/sendGet/analysis/rest/getEstimatePx",
              method: "get",
              params: {
                zf: old.score,
                yzmc: old.languageValue,
                kldm: old.cateValue
              }
            })
              .then(res => {
                this.estimateForm.rate = res.status === 200 ? res.data.px : "";
                localStorage.setItem("hpx", res.data.hpx);
                console.log(res, " estimate score");
              })
              .catch(e => {
                console.error(e);
              });
          }
        }
      },
      deep: true
    }
  }
};
</script>

<style scoped>
.gdap-collegeRcmm {
}

.gdap-collegeRcmm
  .el-radio-button__orig-radio:checked
  + .el-radio-button__inner {
  background-color: #f5ae2d !important;
  border-color: #f5ae2d !important;
  box-shadow: -1px 0 0 0 #f5ae2d !important;
}

.gdap-collegeRcmm .el-radio__input.is-checked + .el-radio__label {
  color: #cf8b6b !important;
}

.gdap-collegeRcmm .el-radio__input.is-checked .el-radio__inner {
  border-color: #cf8b6b !important;
  background: #cf8b6b !important;
}

.gdap-collegeRcmm .gdap-check-active {
  border-bottom: 5px solid #cf8b6b;
  color: #cf8b6b;
}
</style>